<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Trash Stacks: GLib Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-data-types.html" title="GLib Data Types">
<link rel="prev" href="glib-Sequences.html" title="Sequences">
<link rel="next" href="glib-Hash-Tables.html" title="Hash Tables">
<meta name="generator" content="GTK-Doc V1.26.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#glib-Trash-Stacks.description" class="shortcut">Description</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="glib-Sequences.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="glib-Hash-Tables.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="glib-Trash-Stacks"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Trash-Stacks.top_of_page"></a>Trash Stacks</span></h2>
<p>Trash Stacks — maintain a stack of unused allocated memory chunks</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="glib-Trash-Stacks.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Trash-Stacks.html#g-trash-stack-push" title="g_trash_stack_push ()">g_trash_stack_push</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Trash-Stacks.html#g-trash-stack-pop" title="g_trash_stack_pop ()">g_trash_stack_pop</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Trash-Stacks.html#g-trash-stack-peek" title="g_trash_stack_peek ()">g_trash_stack_peek</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Trash-Stacks.html#g-trash-stack-height" title="g_trash_stack_height ()">g_trash_stack_height</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Trash-Stacks.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody><tr>
<td class="datatype_keyword">struct</td>
<td class="function_name"><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack">GTrashStack</a></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Trash-Stacks.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;gmodule.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="glib-Trash-Stacks.description"></a><h2>Description</h2>
<p>A <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> is an efficient way to keep a stack of unused allocated
memory chunks. Each memory chunk is required to be large enough to hold
a <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a>. This allows the stack to be maintained without any space
overhead, since the stack pointers can be stored inside the memory chunks.</p>
<p>There is no function to create a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a>. A <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a>*
is a perfectly valid empty stack.</p>
<p>There is no longer any good reason to use <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a>.  If you have
extra pieces of memory, <code class="function">free()</code> them and allocate them again later.</p>
</div>
<div class="refsect1">
<a name="glib-Trash-Stacks.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="g-trash-stack-push"></a><h3>g_trash_stack_push ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_trash_stack_push (<em class="parameter"><code><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> **stack_p</code></em>,
                    <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data_p</code></em>);</pre>
<div class="warning">
<p><code class="literal">g_trash_stack_push</code> has been deprecated since version 2.48 and should not be used in newly-written code.</p>
<p><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> is deprecated without replacement</p>
</div>
<p>Pushes a piece of memory onto a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a>.</p>
<div class="refsect3">
<a name="g-trash-stack-push.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>stack_p</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data_p</p></td>
<td class="parameter_description"><p>the piece of memory to push on the stack. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL must not be passed as the value in, out, in-out; or as a return value."><span class="acronym">not nullable</span></acronym>]</span></td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-trash-stack-pop"></a><h3>g_trash_stack_pop ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
g_trash_stack_pop (<em class="parameter"><code><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> **stack_p</code></em>);</pre>
<div class="warning">
<p><code class="literal">g_trash_stack_pop</code> has been deprecated since version 2.48 and should not be used in newly-written code.</p>
<p><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> is deprecated without replacement</p>
</div>
<p>Pops a piece of memory off a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a>.</p>
<div class="refsect3">
<a name="g-trash-stack-pop.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>stack_p</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-trash-stack-pop.returns"></a><h4>Returns</h4>
<p> the element at the top of the stack</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-trash-stack-peek"></a><h3>g_trash_stack_peek ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
g_trash_stack_peek (<em class="parameter"><code><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> **stack_p</code></em>);</pre>
<div class="warning">
<p><code class="literal">g_trash_stack_peek</code> has been deprecated since version 2.48 and should not be used in newly-written code.</p>
<p><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> is deprecated without replacement</p>
</div>
<p>Returns the element at the top of a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a>
which may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
<div class="refsect3">
<a name="g-trash-stack-peek.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>stack_p</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-trash-stack-peek.returns"></a><h4>Returns</h4>
<p> the element at the top of the stack</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-trash-stack-height"></a><h3>g_trash_stack_height ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a>
g_trash_stack_height (<em class="parameter"><code><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> **stack_p</code></em>);</pre>
<div class="warning">
<p><code class="literal">g_trash_stack_height</code> has been deprecated since version 2.48 and should not be used in newly-written code.</p>
<p><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> is deprecated without replacement</p>
</div>
<p>Returns the height of a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a>.</p>
<p>Note that execution of this function is of O(N) complexity
where N denotes the number of items on the stack.</p>
<div class="refsect3">
<a name="g-trash-stack-height.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>stack_p</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-trash-stack-height.returns"></a><h4>Returns</h4>
<p> the height of the stack</p>
</div>
</div>
</div>
<div class="refsect1">
<a name="glib-Trash-Stacks.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="GTrashStack"></a><h3>struct GTrashStack</h3>
<pre class="programlisting">struct GTrashStack {
  GTrashStack *next;
};
</pre>
<div class="warning">
<p><code class="literal">GTrashStack</code> has been deprecated since version 2.48 and should not be used in newly-written code.</p>
<p><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> is deprecated without replacement</p>
</div>
<p>Each piece of memory that is pushed onto the stack
is cast to a GTrashStack*.</p>
<div class="refsect3">
<a name="GTrashStack.members"></a><h4>Members</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="300px" class="struct_members_name">
<col class="struct_members_description">
<col width="200px" class="struct_members_annotations">
</colgroup>
<tbody><tr>
<td class="struct_member_name"><p><a class="link" href="glib-Trash-Stacks.html#GTrashStack" title="struct GTrashStack"><span class="type">GTrashStack</span></a> *<em class="structfield"><code><a name="GTrashStack.next"></a>next</code></em>;</p></td>
<td class="struct_member_description"><p>pointer to the previous element of the stack,
gets stored in the first <code class="literal">sizeof (gpointer)</code>
bytes of the element</p></td>
<td class="struct_member_annotations"> </td>
</tr></tbody>
</table></div>
</div>
</div>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.26.1</div>
</body>
</html>